package com.swlz.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.swlz.R;
import com.swlz.vo.LoginUser;
import com.swlz.dto.MallProductSearch;
import com.swlz.entity.MallProduct;
import com.swlz.entity.MallType;
import com.swlz.service.MallProductService;
import com.swlz.service.MallTypeService;
import com.swlz.service.impl.MallProductServiceImpl;
import com.swlz.service.impl.MallTypeServiceImpl;
import com.swlz.servlet.HttpServletSupport;

/**
 * <pre>
 * - JSON控制器
 * - 商城产品
 * ClassName : com.swlz.servlet.demo.MallProductServlet
 * Author : swlz
 * E-Mail : 2233875735@qq.com
 * Date : 2020-07-03 08:52:52
 * Version : 1.0
 * Copyright 2020 swlz.top Inc. All rights reserved. 
 * Warning: this content is only for internal circulation of the company. It is forbidden to divulge it or use it for other commercial purposes
 * </pre>
 **/
@SuppressWarnings("serial")
@WebServlet("/mall-product.let")
public class MallProductServlet extends HttpServlet {
	
	private MallProductService mallProductService = new MallProductServiceImpl();
	private MallTypeService mallTypeService = new MallTypeServiceImpl();
	
//	public String page(HttpServletRequest request,MallProductSearch mallProduct)throws Exception {
//		request.setAttribute("type", mallTypeService.get(mallProduct.getMallTypeId()));
//		request.setAttribute("p", mallProductService.page(mallProduct));
//		return "/mall/product/page";
//	}
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//获取参数
		Long productId = Long.valueOf(request.getParameter("productId"));
		//调用业务逻辑接口
		MallProduct vo = mallProductService.get(productId);
		MallType typeId = mallTypeService.get(vo.getMallTypeId());
		request.setAttribute("vo", vo);
		request.setAttribute("typeId", typeId);
		//跳转视图
		request.getRequestDispatcher("/introduction.jsp").forward(request, response);
	}
	
}